using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;


namespace DataHelper.BLL
{
    public class SEO
    {
        public int ID { get; set; }
        public int LangID { get; set; }
        public string Domain { get; set; }
        public string Keywords { get; set; }
        public string Metadata { get; set; }
        public string Title { get; set; }
        public string Copyright { get; set; }
        public string UpdatedUser { get; set; }
        public DateTime UpdatedDate { get; set; }
        public bool IsDeleted { get; set; }

        #region SEOSelectAll
        public static List<SEO> SEOSelectAll(string strSearch="",int top = 1, int bottom = 20, SqlTransaction ConnectionString = null)
        {
            IDataReader dr = DataHelper.DAL.SEO.SEOSelectAll(strSearch,top,bottom,ConnectionString);
            List<SEO> SEOList = new List<SEO>();
            while(dr.Read())
            {
                SEO mySEO = new SEO
                {
                    ID = !dr.IsDBNull(dr.GetOrdinal("ID")) ? (int)dr["ID"] : 0,
                    LangID = !dr.IsDBNull(dr.GetOrdinal("LangID")) ? (int)dr["LangID"] : 0,
                    Domain = !dr.IsDBNull(dr.GetOrdinal("Domain")) ? (string)dr["Domain"] : null,
                    Keywords = !dr.IsDBNull(dr.GetOrdinal("Keywords")) ? (string)dr["Keywords"] : null,
                    Metadata = !dr.IsDBNull(dr.GetOrdinal("Metadata")) ? (string)dr["Metadata"] : null,
                    Title = !dr.IsDBNull(dr.GetOrdinal("Title")) ? (string)dr["Title"] : null,
                    Copyright = !dr.IsDBNull(dr.GetOrdinal("Copyright")) ? (string)dr["Copyright"] : null,
                    UpdatedUser = !dr.IsDBNull(dr.GetOrdinal("UpdatedUser")) ? (string)dr["UpdatedUser"] : null,
                    UpdatedDate = !dr.IsDBNull(dr.GetOrdinal("UpdatedDate")) ? (DateTime)dr["UpdatedDate"] : DateTime.Now,
                    IsDeleted = !dr.IsDBNull(dr.GetOrdinal("IsDeleted")) ? (bool)dr["IsDeleted"] : false
                };
                SEOList.Add(mySEO);
        }
        dr.Close();
        dr.Dispose();
        return SEOList;
        }
        #endregion
        #region SEOSelectRow
        public static SEO SEOSelectRow(int ID, int LangID, SqlTransaction ConnectionString = null)
        {
            IDataReader dr = DataHelper.DAL.SEO.SEOSelectRow(ID, LangID, ConnectionString);
            SEO seo = null;

            if(dr.Read())
            {
                seo= new SEO
                {
                    ID = !dr.IsDBNull(dr.GetOrdinal("ID")) ? (int)dr["ID"] : 0,
                    LangID = !dr.IsDBNull(dr.GetOrdinal("LangID")) ? (int)dr["LangID"] : 0,
                    Domain = !dr.IsDBNull(dr.GetOrdinal("Domain")) ? (string)dr["Domain"] : null,
                    Keywords = !dr.IsDBNull(dr.GetOrdinal("Keywords")) ? (string)dr["Keywords"] : null,
                    Metadata = !dr.IsDBNull(dr.GetOrdinal("Metadata")) ? (string)dr["Metadata"] : null,
                    Title = !dr.IsDBNull(dr.GetOrdinal("Title")) ? (string)dr["Title"] : null,
                    Copyright = !dr.IsDBNull(dr.GetOrdinal("Copyright")) ? (string)dr["Copyright"] : null,
                    UpdatedUser = !dr.IsDBNull(dr.GetOrdinal("UpdatedUser")) ? (string)dr["UpdatedUser"] : null,
                    UpdatedDate = !dr.IsDBNull(dr.GetOrdinal("UpdatedDate")) ? (DateTime)dr["UpdatedDate"] : DateTime.Now,
                    IsDeleted = !dr.IsDBNull(dr.GetOrdinal("IsDeleted")) ? (bool)dr["IsDeleted"] : false,

                };
            }
        dr.Close();
        dr.Dispose();
        return seo;
        }
        #endregion
        #region SEOInsertRow
        public static void SEOInsertRow(int ID, int LangID, string Domain, string Keywords, string Metadata, string Title, string Copyright, string UpdatedUser, DateTime UpdatedDate, bool IsDeleted, SqlTransaction ConnectionString = null)
        {
            DataHelper.DAL.SEO.SEOInsertRow(ID, LangID, Domain, Keywords, Metadata, Title, Copyright, UpdatedUser, UpdatedDate, IsDeleted, ConnectionString);
        }
        #endregion
        #region SEOUpdateRow
        public static void SEOUpdateRow(int ID, int LangID, string Domain, string Keywords, string Metadata, string Title, string Copyright, string UpdatedUser, DateTime UpdatedDate, bool IsDeleted, SqlTransaction ConnectionString = null)
        {
            DataHelper.DAL.SEO.SEOUpdateRow(ID, LangID, Domain, Keywords, Metadata, Title, Copyright, UpdatedUser, UpdatedDate, IsDeleted, ConnectionString);
        }
        #endregion
        #region SEODeleteRow
        public static void SEODeleteRow(int ID, int LangID, SqlTransaction ConnectionString = null)
        {
            DataHelper.DAL.SEO.SEODeleteRow(ID, LangID,ConnectionString);
        }
        #endregion
    }
}
